﻿using System;
using System.Collections.Generic;
using System.Web.Http.Dependencies;
using YawetagLib.Facade;

namespace YawetagLib.Web.Controllers
{
    public sealed class ApiControllerFactory : IDependencyResolver
    {
        public IDependencyScope BeginScope()
        {
            return this;
        }

        public object GetService(Type serviceType)
        {
            return typeof(BaseApiController).IsAssignableFrom(serviceType)
                ? Activator.CreateInstance(serviceType, FacadeFactoryBuilder.GetFactory())
                : null;
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return new List<object>();
        }

        public void Dispose()
        {
        }
    }
}
